package com.wish.common.log.service;

import com.alibaba.fastjson.JSON;
import com.wish.system.api.RemoteLogService;
import com.wish.system.api.domain.SysOperLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * 异步调用日志服务
 * 
 * @author ruoyi
 */
@Service
public class AsyncLogService
{
    @Autowired
    private RemoteLogService remoteLogService;
    @Autowired
    KafkaTemplate kafkaTemplate;

    /**
     * 保存系统日志记录
     */
    public void saveSysLog(SysOperLog sysOperLog)
    {
        remoteLogService.saveLog(sysOperLog);
    }

    public void kafkaSaveSysLog(SysOperLog sysOperLog){
        String key = UUID.randomUUID().toString();
        kafkaTemplate.send("test",key, JSON.toJSONString(sysOperLog));
    }
}
